<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div class="list-group" id="app">
    <div>
      <a class="list-group-item" v-link="{ path: '/home' }">Home</a>
      <a class="list-group-item" v-link="{ path: '/about' }">About</a>
      <router-view></router-view>
    </div>
  </div>
  <script src="js/vue.js" charset="utf-8"></script>
  <script src="js/vue-router.min.js" charset="utf-8"></script>
  <script type="text/javascript">

    //组件构造器
    var Home = Vue.extend({
      template: '<div><h1>Home</h1><p>{{msg}}</p></div>',
      data: function () {
        return {
          msg: 'Hello, vue router!'
        }
      }
    })

    var About = Vue.extend({
      template: '<div><h1>About</h1><p>This is the tutorial about vue-router.</p></div>'
    })

    //路由实例
    var router = new VueRouter();
    //路由映射
    router.map({
      '/home': {component: Home},
      '/about': {component: About}
    });
    router.redirect({
      '/': '/home'
    });

    //router创建App实例并挂载到#app
    var App = Vue.extend({})
    router.start(App, '#app')
  </script>
</body>
</html>
